import cv2
import numpy as np

def motion_blur(img, size):
    # 创建水平方向的运动模糊核
    kernel_motion_blur = np.zeros((size, size))
    kernel_motion_blur[int((size-1)/2), :] = np.ones(size)
    kernel_motion_blur = kernel_motion_blur / size

    # 应用核到图像
    img_blurred = cv2.filter2D(img, -1, kernel_motion_blur)

    return img_blurred



if __name__ == '__main__':

    img = cv2.imread(r"C:\Users\luoluoluo\Desktop\211.jpg")
    img = cv2.convertScaleAbs(img, alpha=0.6, beta=0)
    img = motion_blur(img, 15)
    mirror = cv2.imread(r"C:\Users\luoluoluo\Desktop\Snipaste_2023-10-27_16-29-58.jpg")
    print(mirror.shape)
    img = cv2.resize(img, (mirror.shape[1], mirror.shape[0]))
    blended = cv2.addWeighted(img, 0.5, mirror, 0.6, 0)
    blended = motion_blur(blended, 30)
    cv2.imshow("11", img)
    cv2.waitKey(0)
